package org.example.thread.testReturn.way1;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author liyishan
 * @date 2023/8/3 11:33
 * @apiNote
 */

public class testReturn {
    public static void main(String[] args) {
        test2();
    }

    private static void test1(){
        TaskCallable<TaskResult> taskCallable = new TaskHandler();
        TaskExecutor taskExecutor = new TaskExecutor(taskCallable,"测试回调任务");
        new Thread(taskExecutor).start();

    }


    private static void test2(){
        //创建一个默认线程池
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,
                10,
                100,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(1000));
        TaskCallable<TaskResult> taskCallable = new TaskHandler();
        TaskExecutor taskExecutor = new TaskExecutor(taskCallable,"测试回调任务");
        for(int i=0;i<5;i++){
            threadPoolExecutor.execute(taskExecutor);
        }

    }




}
